<?php
namespace app\mobile\controller;
use think\Db;


class IndexController extends WechatController
{
    public function index()
    {
    	/*$this->wx_user = session("wx_user_info");
		if(!$this->wx_user){
			$response = $this->app->oauth->scopes(['snsapi_userinfo'])->redirect();
        	$response->send();
		}*/
    	$slider = Db::name('slide_item')->where('slide_id',1)->where('status',1)->order('list_order asc')->field('title,image,url')->select()->all();
        //dump($slider);
        $this->assign('slider',$slider);
        return $this->fetch();
    }
    /** 加入我们*/
    public function join_us(){
        return $this->fetch('register');
    }
    /** 新闻中心*/
    public function news(){
        $list =get_mobile_list(10);
        $this->assign('list',$list);
        $this->assign('title','新闻中心');
        return $this->fetch('news_list');
    }
    /** 最新公告*/
    public function notice(){
        $list =get_mobile_list(9);
        $this->assign('list',$list);
        $this->assign('title','最新公告');
        return $this->fetch('news_list');
    }
    /** 志愿项目*/
    public function program(){
        $list =get_mobile_list(12);
        $this->assign('list',$list);
        $this->assign('title','志愿者服务项目');
        return $this->fetch('news_list');
    }
    /** 志愿者服务*/
    public function server(){
        $list =get_mobile_list(12);
        $this->assign('list',$list);
        $this->assign('title','志愿者服务');
        return $this->fetch('news_list');
    }
    /** 扫码打卡*/
    public function scan(){
        return $this->fetch();
    }
    /** 志愿者培训*/
    public function train(){
        $cate = Db::name('portal_category')->where('parent_id',4)->field('id,name')->select();
        $lists =[];
        foreach ($cate as $k=>$v){
            $lists[$v['name']]=get_mobile_list($v['id']);
        }
        //dump($lists);
        //$list =get_list(4);
        $this->assign('lists',$lists);
        $this->assign('title','志愿者培训');
        return $this->fetch('news_lists');
    }
    /** 志愿者风采*/
    public function show(){
        $cate = Db::name('portal_category')->where('parent_id',3)->field('id,name')->select();
        $lists =[];
        foreach ($cate as $k=>$v){
            $lists[$v['name']]=get_mobile_list($v['id']);
        }
        $this->assign('lists',$lists);
        $this->assign('title',' 志愿者风采');
        return $this->fetch('news_lists');
    }



}
